<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .active {
            color: red;
        }
    </style>
</head >
<body>
<script src="../js/vue.js"> </script>

<div id="app">
    <!-- 作业要求见03-04-作业(v-for和v-bind的结合)  -->
    <ul>
        <li v-for="(item, index) in movies" :class="{active: curIndex==index}" v-on:click="setCurIndex(index)">{{item}}</li>
    </ul>
</div>
<script>
    const app = new Vue({
        el: "#app",
        data: {
            msg: "hello",
            movies: [
                "星际穿越",
                "大话西游",
                "少年派",
                "盗梦空间"
            ],
            curIndex: 0
        },
        methods: {
            setCurIndex(index) {
                this.curIndex = index
            }
        }
    })
</script>
</body>
</html>